#include "hud_skill.h"
#include "../affiliate/sprite.h"
hud_skill *hud_skill::createHubSkill(node *parent, const char *path,const char *name,glm::vec2 pos,
    float scale,Anchor anchor)
{
    auto hub = new hud_skill();
    hub ->init();
    hub->name_ = name;
    hub->icon_ = sprite::createSprite(hub,path,scale,anchor);
    hub->setRenderPosition(pos);
    if(parent) parent->addChild(hub);
    return hub;
}

void hud_skill::render()
{
    SDL_SetTextureColorModFloat(icon_->getData().texture,0.3f,0.3f,0.3f);
    game_.renderSprite(icon_->getData(),getRenderPosition() + icon_->get_offset(),
        icon_->getSize());
    SDL_SetTextureColorModFloat(icon_->getData().texture,1.0f,1.0f,1.0f);
    screen::render();

}

void hud_skill::setPrecent(float precent)
{
    precent = glm::clamp(precent,0.0f,1.0f);
    precent_=precent;
    if(icon_)
    {
        icon_->setPreScale(glm::vec2(1.0f,precent));
    }
}
